<template>
	<view class="container">
		<u-toast ref="uToast" />
		<u-navbar :is-back="true" title="待审核详情" back-icon-color='#333333' height="50" :border-bottom="false">
		</u-navbar>
		<u-mask :show="display">
			<view class="warp">
				<view class="rect" @tap.stop>
					<view class="tanchu">
						是否取消此教师用车?
					</view>
					<view class="anniu">
						<view class="" @click="display=false">
							取消
						</view>
						<view class="" @click="deleteApply">
							确定
						</view>
					</view>
				</view>
			</view>
		</u-mask>
		<view class="list">
			<view class="apply">
				<text>申请人:</text>
				<text>{{teacher}}</text>
			</view>
			<view class="service_time">
				<view class="use">
					<text>使用时间</text>
				</view>
				<view class="time">
					<view class="top">
						<text>{{start_date}}</text>
					</view>
					<view class="bottom">
						<text>{{end_date}}</text>
					</view>
				</view>
			</view>
			<view class="vehicle">
				<text>车辆</text>
				<view class="select">
					<text>{{obj?obj.name:''}}</text>
					<text></text>
				</view>
			</view>
			<view class="blank" style="width: 100%; height: 18rpx;">
			</view>
			<view class="vehicle_info">
				<view class="license">
					<text>车牌号码:</text>
					<text>{{obj?obj.no:''}}</text>
					<text>司机:</text>
					<text>{{obj?obj.driver_name:''}}</text>
				</view>
				<view class="available">
					<text>可载人数:</text>
					<text>{{obj?obj.people:''}}</text>
					<text>电话:</text>
					<text>{{obj?obj.driver_phone:''}}</text>
				</view>
				<view class="picture">
					<view class="photo">
						<text>图片</text>
					</view>
					<view class="photo_list">
						<image :src="item" mode="widthFix" v-for="(item,index) in img_arr" :key="index"></image>
					</view>
				</view>
				<view class="" style="width: 100%; height: 30rpx;">

				</view>
			</view>
			<view class=" " style="width: 94%; margin-left: 3%; height: 30rpx; border-bottom:1rpx solid #F2F2F2;">

			</view>
			<view class="event">
				<text>事件</text>
				<text>{{event}}</text>
			</view>
			<view class="" style="width:100%; height:15rpx; background:#fff;">
			</view>
		</view>
		<view class="confirm">
			<view class="cancel" @click.stop="display=true">
				{{cancel}}
			</view>
			<view class="verify" @click.stop="changePath">
				{{verify}}
			</view>

		</view>
	</view>
</template>

<script>
	import time from '../../time.js'
	import request from '../../request.js'
	export default {
		data() {
			return {
				left_color: '#fff',
				left_background_color: '#2E98FA',
				verify: '修改申请',
				cancel: '取消申请',
				right_color: '#333333',
				content: '',
				right_background_color: '#F2F2F2',
				form: {
					car_id: '',
					start_time: '',
					end_time: '',
					event: '',
					apply_id: '',
				},
				obj: {

				},
				display: false,
				delivery_obj: {},
				img_arr: [],
				teacher: '',
				event: '',
				start_date: '',
				end_date: '',
			}
		},
		onLoad(option) {
			if (option.obj) {
				this.delivery_obj = JSON.parse(decodeURIComponent(option.obj));
				console.log(this.delivery_obj);
				console.log(option.obj);
				this.form.apply_id = this.delivery_obj.apply_id;
				this.form.car_id = this.delivery_obj.car_id;
				this.form.start_time = this.delivery_obj.start_time;
				this.form.end_time = this.delivery_obj.end_time;
				this.form.event = this.delivery_obj.event;
				this.obj = this.delivery_obj.car_info ? this.delivery_obj.car_info : null;
				this.teacher = this.delivery_obj.teacher_info ? this.delivery_obj.teacher_info.full_name : '';
				let arr = this.delivery_obj.car_info ? this.delivery_obj.car_info.pics.split(',') : [];
				this.img_arr = arr;
				this.event = this.delivery_obj.event;
				this.start_date = time.format(this.delivery_obj.start_time);
				this.end_date = time.format(this.delivery_obj.end_time);
			}
		},
		methods: {
			changeLeftColor() {
				if (this.left_background_color == '#2E98FA') {
					this.left_color = '#333333';
					this.left_background_color = '#F2F2F2';
					this.right_color = '#fff';
					this.right_background_color = '#2E98FA';
				} else {
					this.left_color = '#fff';
					this.left_background_color = '#2E98FA';
					this.right_color = '#333333';
					this.right_background_color = '#F2F2F2';
				}
			},
			changePath() {
				switch (this.delivery_obj == null) {
					case true:
						this.$toLink('../add_apply/add_apply', {})
						break;
					default:
						this.$toLink('../add_apply/add_apply', {
							obj: encodeURIComponent(JSON.stringify(this.delivery_obj)),
						})
				}
			},
			changeRightColor() {
				if (this.right_background_color == '#2E98FA') {
					this.right_color = '#333333';
					this.right_background_color = '#F2F2F2';
					this.left_color = '#fff';
					this.left_background_color = '#2E98FA';
				} else {
					this.right_color = '#fff';
					this.right_background_color = '#2E98FA';
					this.left_color = '#333333';
					this.left_background_color = '#F2F2F2';
				}
			},
			deleteApply() {
				this.display = false;
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				let _this = this;
				request({
					url: base_url + 'teacher/carApply/delete',
					method: 'post',
					data: {
						...this.form,
					},
					success(res) {
						if (res.statusCode == 200) {
							_this.$toLink('../teacher_car/teacher_car', {}, 2)
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},
		}

	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		height: 100vh;
		background-color: #F2F2F2;
		overflow: hidden;

		.warp {
			display: flex;
			align-items: flex-start;
			justify-content: center;
			height: 100%;

			.rect {
				margin-top: 450rpx;
				border-radius: 10rpx;
				width: 480rpx;
				height: 250rpx;
				background-color: #fff;

				.tanchu {
					width: 100%;
					height: 150rpx;
					font-size: 33rpx;
					color: #3E3E3E;
					text-align: center;
					line-height: 150rpx;
				}

				.anniu {
					width: 100%;
					height: 100rpx;
					display: flex;
					justify-content: space-around;
					align-items: center;

					view {
						border-radius: 30rpx;
						width: 150rpx;
						height: 60rpx;
						text-align: center;
						line-height: 60rpx;
						font-size: 26rpx;

						&:nth-child(1) {
							color: #2C78FE;
							margin-left: 15rpx;
							border: 1px solid #2C78FE;
							background: #fff;

						}

						&:nth-child(2) {
							color: #fff;
							margin-right: 15rpx;
							background: linear-gradient(to right, #2C78FE, #32B0FF);
						}


					}
				}
			}
		}

		.list {
			width: 100%;
			background-color: #fff;
			margin-top: 30rpx;

			.apply {
				width: 94%;
				margin-left: 3%;
				height: 88rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				border-bottom: 1rpx solid #F2F2F2;


				text {
					color: #333333;
					font-size: 30rpx;

					&:nth-child(1) {}

					&:nth-child(2) {
						margin-left: 5rpx;
					}
				}
			}

			.service_time {
				width: 94%;
				margin-left: 3%;
				height: 134rpx;
				display: flex;
				justify-content: flex-start;

				.use {
					width: 120rpx;
					height: 134rpx;
					display: flex;
					justify-content: flex-start;

					text {
						&:nth-child(1) {
							color: #666666;
							font-size: 26rpx;
							margin-top: 31rpx;
						}
					}
				}

				.time {
					margin-top: 28rpx;
					margin-left: 24rpx;
					width: 400rpx;
					height: 134rpx;

					.top {
						height: 28rpx;
						width: 100%;
						display: flex;
						justify-content: flex-start;

						text {
							color: #333333;
							font-size: 26rpx;
							height: 28rpx;

							&:nth-child(1) {
								width: 400rpx;
							}
						}
					}

					.bottom {
						height: 28rpx;
						margin-top: 20rpx;
						width: 100%;
						display: flex;
						justify-content: flex-start;

						text {
							color: #333333;
							font-size: 26rpx;
							height: 28rpx;

							&:nth-child(1) {
								width: 400rpx;
							}
						}
					}

				}
			}

			.vehicle {
				width: 94%;
				margin-left: 3%;
				height: 52rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
						height: 28rpx;
						width: 130rpx;
					}
				}

				.select {
					width: 285rpx;
					height: 50rpx;
					display: flex;
					justify-content: flex-start;
					align-items: center;
					border: 1rpx solid #F2F2F2;
					margin-left: 10rpx;

					text {
						&:nth-child(1) {
							width: 200rpx;
							color: #333333;
							font-size: 26rpx;
							height: 30rpx !important;
							line-height: 30rpx;
							margin-left: 10rpx;
						}

						&:nth-child(2) {
							width: 0rpx;
							height: 0rpx;
							margin-top: 15rpx;
							margin-left: 20rpx;
							border-width: 14rpx 14rpx 14rpx 14rpx;
							border-color: #ccc transparent transparent transparent;
							border-style: solid;
						}
					}
				}
			}

			.vehicle_info {
				width: 94%;
				margin-left: 3%;
				background-color: #F2F2F2;
				border-radius: 8rpx;

				.license {
					width: 100%;
					display: flex;
					justify-content: flex-start;
					height: 52rpx;

					text {
						color: #333333;
						font-size: 26rpx;
						height: 28rpx;
						margin-top: 22rpx;

						&:nth-child(1) {
							width: 130rpx;
							margin-left: 15rpx;
						}

						&:nth-child(2) {
							width: 150rpx;
						}

						&:nth-child(3) {
							margin-left: 80rpx;
							width: 95rpx;
						}

						&:nth-child(4) {}
					}
				}

				.available {
					width: 100%;
					height: 52rpx;
					display: flex;
					justify-content: flex-start;

					text {
						color: #333333;
						font-size: 26rpx;
						height: 28rpx;
						margin-top: 22rpx;

						&:nth-child(1) {
							width: 130rpx;
							margin-left: 15rpx;
						}

						&:nth-child(2) {
							width: 150rpx;
						}

						&:nth-child(3) {
							margin-left: 80rpx;
							width: 95rpx;
						}

						&:nth-child(4) {}
					}
				}

				.picture {
					width: 100%;
					display: flex;
					justify-content: flex-start;
					margin-top: 25rpx;

					.photo {
						width: 80rpx;
						display: flex;
						justify-content: flex-start;

						text {
							&:nth-child(1) {
								color: #333333;
								font-size: 26rpx;
								margin-left: 15rpx;
							}
						}
					}

					.photo_list {
						width: 450rpx;
						display: flex;
						justify-content: flex-start;
						flex-wrap: wrap;

						image {
							width: 163rpx;

							&:nth-child(n+1) {
								margin-left: 24rpx;
							}
						}
					}

				}
			}

			.event {
				width: 94%;
				height: 60rpx;
				margin-left: 3%;
				display: flex;
				justify-content: flex-start;

				text {
					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
						height: 28rpx;
						margin-top: 20rpx;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
						width: 450rpx;
						margin-top: 20rpx;
						font-size: 26rpx;
						overflow:hidden;
					}
				}
			}

			.result {
				width: 94%;
				margin-left: 3%;
				height: 100rpx;
				display: flex;
				justify-content: flex-start;

				.accept {
					height: 28rpx;
					width: 150rpx;
					font-size: 26rpx;
					color: #666666;
					margin-top: 38rpx;
				}

				#toggle {
					width: 200rpx;
					height: 40rpx;
					margin-top: 35rpx;
					position: relative;

					#passed {
						width: 80rpx;
						height: 40rpx;
						color: #fff;
						text-align: center;
						border-top-left-radius: 20rpx;
						position: absolute;
						left: 0rpx;
						top: 0rpx;
						border-bottom-left-radius: 20rpx;
						background-color: #2D82FF;
						line-height: 40rpx;
						font-size: 20rpx;
					}

					#reject {
						width: 80rpx;
						height: 40rpx;
						color: #333333;
						position: absolute;
						left: 80rpx;
						top: 0rpx;
						text-align: center;
						border-top-right-radius: 20rpx;
						border-bottom-right-radius: 20rpx;
						background-color: #F2F2F2;
						line-height: 40rpx;
						font-size: 20rpx;
					}
				}
			}

			.remarks {
				width: 94%;
				height: 60rpx;
				margin-left: 3%;
				display: flex;
				justify-content: flex-start;
				font-size: 26rpx;
				color: #666666;

			}
		}

		.confirm {
			width: 100%;
			margin-top: 100rpx;
			height: 300rpx;
			display: flex;
			justify-content: space-around;
			align-items: center;

			.verify {
				width: 200rpx;
				height: 60rpx;
				border-radius: 50rpx;
				text-align: center;
				line-height: 60rpx;
				background: linear-gradient(to right, #2C78FE, #32B0FF);
				color: #fff;
				font-size: 30rpx;
			}

			.cancel {
				width: 200rpx;
				height: 60rpx;
				border-radius: 50rpx;
				text-align: center;
				line-height: 60rpx;
				background: #fff;
				color: #666666;
				font-size: 30rpx;
			}
		}

	}
</style>
